#include<bits/stdc++.h>
#define ll long long
#define mxn 100003
#define md 1000000007
#define pb push_back
#define mkp make_pair
#define pq priority_queue
#define rep(i,a,b) for(int i=a;i<=b;++i)
#define rept(i,a,b) for(int i=a;i<b;++i)
#define drep(i,a,b) for(int i=a;i>=b;--i)
#define umap unordered_map
using namespace std;
inline int read(){
    int x=0;bool fl=0;char c=getchar();
    while(!isdigit(c)){if(c=='-')fl=1;c=getchar();}
    while(isdigit(c))x=(x<<3)+(x<<1)+(c^48),c=getchar();
    return fl?-x:x;
}
struct node{
    int d,v,a;
}ad[mxn];
struct nde{
    int r,x;
}d[mxn];
int T,n,m,l,v,t,ans,a[mxn],dp[mxn],f[mxn];
void upd(int x,int y){
    x++;
    for(;x;x-=x&-x)f[x]=min(f[x],y);
}
int ask(int x){
    int ans=1e9;x++;
    for(;x<=m+1;x+=x&-x)ans=min(ans,f[x]);
    return ans;
}
void solve(){
    n=read(),m=read(),l=read(),v=read();
    rep(i,1,n)ad[i].d=read(),ad[i].v=read(),ad[i].a=read();
    rep(i,1,m)a[i]=read();
    ans=0,t=0;
    rep(i,1,n){
        if(ad[i].a==0){
            if(ad[i].v>v){
                int L=lower_bound(a+1,a+m+1,ad[i].d)-a;
                if(L<=m){
                    d[++t]={m,L};
                    ans++;
                }
            }
        }else if(ad[i].a>0){
            int d1=min((ll)ad[i].d+(ad[i].v>v?0:(ll)(ad[i].v+v)*(v-ad[i].v)%(ad[i].a*2)==0?(ll)(ad[i].v+v)*(v-ad[i].v)/ad[i].a/2+1:(ll)ceil((double)(ad[i].v+v)*((double)(v-ad[i].v)/ad[i].a)/2)),l+1ll);
            if(d1<=l){
                int L=lower_bound(a+1,a+m+1,d1)-a;
                if(L<=m){
                    d[++t]={m,L};
                    ans++;
                }
            }
        }else if(ad[i].v>v){
            int a1=-ad[i].a,d1=min((ll)ad[i].d+((ll)(ad[i].v+v)*(ad[i].v-v)%(a1*2)==0?(ll)(ad[i].v+v)*(ad[i].v-v)/a1/2-1:(ll)floor((double)(ad[i].v+v)*((double)(ad[i].v-v)/a1)/2)),l+1ll);
            if(d1>=ad[i].d){
                int L=lower_bound(a+1,a+m+1,ad[i].d)-a,ez=upper_bound(a+1,a+m+1,d1)-a-1;
                if(L<=m&&a[L]<=d1){
                    d[++t]={ez,L};
                    ans++;
                }
            }
        }
    }
    sort(d+1,d+t+1,[](nde x,nde y){
        return x.r<y.r;
    });
    int rt=1,mx=0;
    rep(i,1,m+1)f[i]=1e9;
    dp[0]=0;
    upd(0,0);
    rep(i,1,m){
        while(rt<=t&&d[rt].r<i){
            mx=max(mx,d[rt].x);
            rt++;
        }
        dp[i]=ask(mx)+1;
        // cout<<i<<":"<<mx<<" "<<dp[i]<<'\n';
        upd(i,dp[i]);
    }
    while(rt<=t)mx=max(mx,d[rt].x),rt++;
    cout<<ans<<' '<<m-ask(mx)<<'\n';
}
signed main(){
    freopen("detect.in","r",stdin);
    freopen("detect.out","w",stdout);
    T=read();
    while(T--)solve();
    return 0;
}